package controller

import (
	"github.com/cyfqyb/fiber_demo/utils"
	"github.com/gofiber/fiber/v2"
)

func init() {
	RegisterRoute(func(app *fiber.App) {
		common := app.Group("/common")
		common.Post("/upload", uploadFile)
	})
}

func uploadFile(c *fiber.Ctx) error {
	file, err := c.FormFile("file")
	if err != nil {
		return Fail(c, "上传失败")
	}
	filePath := utils.UploadAliyunOss(file)

	return Success(c, filePath)
}
